package com.woniuxy.main.service.imp;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.woniuxy.main.mapper.MessagesMapper;
import com.woniuxy.main.pojo.Messages;
import com.woniuxy.main.service.MessagesService;

import lombok.Data;

@Data
@Service
@Transactional
public class MessagesServiceImpl implements MessagesService{
	@Autowired
	private MessagesMapper messagesMapper;

	/**
	 * 添加聊天记录
	 */
	@Override
	public void saveChatRecord(Messages messages) {		
		messagesMapper.saveChatRecord(messages);
	}

	/**
	 * 获取历史记录
	 */
	@Override
	public List<Messages> getHistoryMessages(Messages messages) {		
		return messagesMapper.getHistoryMessages(messages);
	}

	/**
	 * 获取聊天对象id
	 */
	@Override
	public int[] messagesAsUid(Messages messages) {
		return messagesMapper.messagesAsUid(messages);
	}

	/**
	 * 获取用户id
	 */
	@Override
	public int[] messagesAsTalker(Messages messages) {
		return messagesMapper.messagesAsTalker(messages);
	}
	
	/**
	 * 获取指定用户昵称
	 */
	@Override
	public String getNickName(int uid) {
		return messagesMapper.getNickName(uid);
	}

}
